﻿using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Primitives;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace MyFramework.Web.Api
{
    /// <summary>
    /// 
    /// </summary>
    public class MyActionDescriptorChangeProvider : IActionDescriptorChangeProvider
    {
        /// <summary>
        /// 
        /// </summary>
        public static MyActionDescriptorChangeProvider Instance { get; } = new MyActionDescriptorChangeProvider();
        /// <summary>
        /// 
        /// </summary>
        public CancellationTokenSource TokenSource { get; private set; }
        /// <summary>
        /// 
        /// </summary>
        public bool HasChanged { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IChangeToken GetChangeToken()
        {
            TokenSource = new CancellationTokenSource();
            return new CancellationChangeToken(TokenSource.Token);
        }
    }
}
